<?php


namespace app\common\library\aliyunsms;


use think\facade\Log;

class alidayu
{
    var $sms;

    public function __construct()
    {
        $this->sms = new Sms(config('app.alidayu'));
    }

    function send_verify_msg($phone, $code)
    {
        $params = [
            'code' => $code,
        ];

        $tmp_code = ALERT_SMS_TML_VERIFY_CODE;

        $result = $this->sms->send($tmp_code, $phone, $params);
        Log::debug("alidayu {$phone} {$tmp_code} {$result}");
    }

    function send_bind_authed_user_msg($phone, $code)
    {
        $params = [
            'code' => $code,
        ];

        $tmp_code = SMS_TPL_BIND_AUTHED_USER;

        $result = $this->sms->send($tmp_code, $phone, $params);
        Log::debug("alidayu {$phone} {$tmp_code} {$result}");
    }

    function send_sms_reset_passwd($phone, $passwd)
    {
        $params = [
            'passwd' => $passwd,
        ];

        $tmp_code = SMS_TPL_RESET_PASSWD;

        $result = $this->sms->send($tmp_code, $phone, $params);
        Log::debug("alidayu {$phone} {$tmp_code} {$result}", $params);
    }

    function send_sms_alert($phone, $tmp_code, $data)
    {
        $result = $this->sms->send($tmp_code, $phone, $data);
        Log::debug("alidayu {$phone} {$tmp_code} {$result}");
    }

    function send_sms_ride_order_finish($phone, $miles, $duration, $amount)
    {
        $params = [
            'miles' => $miles,
            'duration' => $duration,
            'amount' => $amount,
        ];

        $tmp_code = SMS_TPL_RIDE_ORDER_FINISH;

        $result = $this->sms->send($tmp_code, $phone, $params);
        Log::debug("alidayu {$phone} {$tmp_code} {$result}");
    }

    function send_sms_user_ride_violation($phone)
    {
        $params = [
        ];

        $tmp_code = SMS_TPL_USER_RIDE_VIOLATION;

        $result = $this->sms->send($tmp_code, $phone, $params);
        Log::debug("alidayu {$phone} {$tmp_code} {$result}");
    }

}